/**
 * Licensed under the Apache License Version 2.0.
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package net.interknit.knitter.cg.template;

import java.util.List;
import java.util.Vector;

import net.interknit.knitter.cg.model.JavaType;
import net.interknit.knitter.cg.model.JavaTypeScanner;
import net.interknit.knitter.cg.view.JavaTypeViewFactory;
import net.interknit.knitter.cg.view.SeedTypeHolder;

/**
 *
 */
public class TemplateBuilder
{
	private static List<Template> templates = new Vector<Template>();

	public static List<Template> build(JavaTypeScanner scanner)
	{
		scanner.assertScanComplete();

		for(JavaType javaType : scanner.getJavaTypes())
		{
			templates.add(JavaTypeViewFactory.create(javaType).build());
		}

		templates.add(CustomTypeDefTemplateHolder.getInstance().getTypeDefTemplate().build());

		for(ParameterBeanTemplate pb : ParameterBeanTemplateHolder.getInstance().getAll())
		{
			templates.add(pb.build());
		}

		return templates;
	}

	public static void clear()
	{
		templates.clear();

		CustomTypeDefTemplateHolder.getInstance().clear();
		ParameterBeanTemplateHolder.getInstance().clear();
		SeedTypeHolder.getInstance().clear();
	}
}
